import React, { createContext, useContext } from "react";
import { useBountyMock } from "./useBountyMock";

// 创建上下文
const BountyContext = createContext(null);

// 提供者组件
export const BountyProvider = ({ children }) => {
  const bountyMock = useBountyMock();

  return (
    <BountyContext.Provider value={bountyMock}>
      {children}
    </BountyContext.Provider>
  );
};

// 使用上下文的Hook
export const useBounty = () => {
  const context = useContext(BountyContext);
  if (!context) {
    throw new Error("useBounty必须在BountyProvider内部使用");
  }
  return context;
};

export default BountyContext;
